package net.kengo.volleyball.scheduler.data;

import java.io.*;
import java.util.*;

public class Week extends ArrayList
{
   int       weekNum = 0;

   public Week( int weekNum )
   {
      super();

      this.weekNum = weekNum;
   }


   public int getNumMatches()
   {
      int numMatches = 0;
      for (int ii=0; ii<super.size(); ii++)
      {
         GameDay day = (GameDay)super.get(ii);
         numMatches += day.getNumMatches();
      }

      return numMatches;
   }


   public String toString()
   {
      String output = new String();

      output += "        <TR>\n";

      output += "          <TD ROWSPAN=" + getNumMatches() + ">\n";
      output += "            <center>" + weekNum + "</center>\n";
      output += "          </TD>\n";
      
      int numGameDays = super.size();

      if ( numGameDays == 0 )
      {
         output += "          <TD COLSPAN=4>\n";
         output += "          <center>No matches this week.</center>\n";
         output += "          </TD>\n";
      }
      else
      {
         for ( int ii=0; ii<numGameDays; ii++ )
         {
            GameDay gameDay = (GameDay)super.get(ii);
            output += gameDay;
         }
      }

      return output;
   }
}
